using System;
using System.Collections.Generic;
using System.Text;

using KmlUtils;

namespace StormModelToKMLDB
{
    public class Radar
    {
        public enum RadarType
        {
            LongReflect = 0,
            CompositeReflect = 1,
            Velocity = 2,
            RelativeMotion = 3,
            OneHrPrecip = 4,
            TotPrecip = 5,
            Warnings = 6
        }

        private RadarType _type;

        public RadarType RadType
        {
            get { return _type; }
            set { _type = value; }
        }
        private string _imgLink;

        public string ImgLink
        {
            get { return _imgLink; }
            set { _imgLink = value; }
        }
        private string _description;

        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }
        private double _north;

        public double North
        {
            get { return _north; }
            set { _north = value; }
        }
        private double _south;

        public double South
        {
            get { return _south; }
            set { _south = value; }
        }
        private double _east;

        public double East
        {
            get { return _east; }
            set { _east = value; }
        }
        private double _west;

        public double West
        {
            get { return _west; }
            set { _west = value; }
        }
        private Point _centerLoc;

        public Point CenterLoc
        {
            get { return _centerLoc; }
            set { _centerLoc = value; }
        }

        public Radar(string dataLine)
        {
            this.Parse(dataLine);
        }

        private void Parse(string line)
        {
            string[] toks = line.Split(';');
            switch (toks[0])
            {
                case "0":
                    this._type = RadarType.LongReflect;
                    break;
                case "1":
                    this._type = RadarType.CompositeReflect;
                    break;
                case "2":
                    this._type = RadarType.Velocity;
                    break;
                case "3":
                    this._type = RadarType.RelativeMotion;
                    break;
                case "4":
                    this._type = RadarType.OneHrPrecip;
                    break;
                case "5":
                    this._type = RadarType.TotPrecip;
                    break;
                case "6":
                    this._type = RadarType.Warnings;
                    break;
                default:
                    this._type = RadarType.LongReflect;
                    break;
            }
            this._imgLink = toks[1];
            this._description = toks[2];
            this._north = double.Parse(toks[3]);
            this._south = double.Parse(toks[4]);
            this._east = double.Parse(toks[5]);
            this._west = double.Parse(toks[6]);
            this._centerLoc = new Point(AltitudeMode.clampToGround, (this._north + this._south) / 2.0, (this._east + this._west) / 2.0, 0);
        }
    }
}
